package com.rany.day10.demo05;

import com.rany.day10.demo04.RegisterException;

import java.util.Arrays;
import java.util.Scanner;

public class RegisterTest {
    static String[] nameArray = {"lin","lulu","gu","xiong"};
    public static void main(String[] args) /*throws RegisterException*/ {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您的名字");
        String userName = scanner.next();
        nameCheck(userName);
        System.out.println(Arrays.toString(nameArray));
    }

    public static void nameCheck(String next) /*throws RegisterException*/ {
        for (String s : nameArray) {
            if (s.equals(next)){
                throw new RegisterException2("该用户已经被注册！");
            }
            return;
        }
        System.out.println("添加成功！");
    }
}
